package com.xh.bussiness.resource.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xh.bussiness.resource.bean.request.MaterialOperateLogRequest;
import com.xh.bussiness.resource.dao.MaterialOperateLogMapper;
import com.xh.bussiness.resource.model.MaterialOperateLog;
import com.xh.bussiness.resource.service.IMaterialOperateLogService;
import com.xh.core.bean.XhPage;
import com.xh.core.service.impl.BaseServiceImpl;

/**
 * <p>
 * 资料操作日志 服务实现类
 * </p>
 *
 * @author JQM
 * @since 2019-08-27
 */
@Service
public class MaterialOperateLogServiceImpl extends BaseServiceImpl<MaterialOperateLogMapper, MaterialOperateLog> implements IMaterialOperateLogService {
    @Override
    public XhPage queryMaterialOperateLogPage(XhPage page, MaterialOperateLogRequest bean) {
        QueryWrapper qw=new QueryWrapper<MaterialOperateLog>();
        //拼装条件
        qw=prepareParams(bean, qw);

        return (XhPage) this.dao.selectPage(page,qw);
    }

    @Override
    public List queryMaterialOperateLog(MaterialOperateLogRequest bean) {
        QueryWrapper qw=new QueryWrapper<MaterialOperateLog>();
        //拼装条件
        qw=prepareParams(bean, qw);

        return this.dao.selectList(qw);
    }


    /**
     * 准备条件
     * @param bean
     * @param qw
     */
    private QueryWrapper prepareParams(MaterialOperateLogRequest bean, QueryWrapper qw) {
        if(bean.getIds()!=null&&bean.getIds().length>0){
            qw.in("id",bean.getIds());
        }
        return qw;
    }
}
